package com.qqtech.qquan.homemaking.dao;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import com.qqtech.core.common.util.BeanUtil;
import com.qqtech.core.frame.dao.BaseDaoImpl;
import com.qqtech.core.frame.dao.SqlId;
import com.qqtech.qquan.homemaking.model.*;

@Repository
public class HomemakingOrderDaoImpl extends BaseDaoImpl<HomemakingOrder> implements HomemakingOrderDao {
	public static final Logger log = LoggerFactory.getLogger(HomemakingOrderDaoImpl.class);
	
	public HomemakingOrderVo getByOrderNo(java.lang.String orderNo) {
		return sqlSessionTemplate.selectOne(getSqlName("selectByOrderNo"), orderNo);
	}

	@Override
	public int queryCountByDoneAt(HomemakingOrderQuery query) {
		if (query == null) {
			return 0;
		}
		return sqlSessionTemplate.selectOne(getSqlName("selectCountByDoneAt"), BeanUtil.toMap(query));
	}

	@Override
	public Page<HomemakingOrderVo> queryPageListBySeller(
			HomemakingOrder query, Pageable pageable) {
		List<HomemakingOrderVo> contentList = sqlSessionTemplate.selectList(getSqlName("selectBySeller"), getParams(query, pageable));
		return new PageImpl<HomemakingOrderVo>(contentList, pageable, this.queryCount(query));
	}	
}
